package com.example.classes;

import com.google.gson.JsonElement;
import com.google.gson.JsonSerializer;

import java.util.ArrayList;
import java.util.List;

/**
 * @author Ali Abid
 * Represents a Member account
 */
public class Member
{
	private String name, password, contact;
    protected boolean locked;

    /**
     * gets items lost by this Member
     * @return ArrayList of items lost by this user
     */
    public List<Item> getItems() {
        return items;
    }

    /**
     * defines the list of items lost by this Member
     * @param items ArrayList of items lost
     */
    public void setItems(List<Item> items) {
        this.items = items;
    }

    /**
     * gives state of Member
     * @return lock state of Member
     */
    public boolean isLocked() {
        return locked;
    }

    /**
     * sets lock state of member
     * @param locked true if this Member should be locked
     */
    public void setLocked(boolean locked) {
        this.locked = locked;
    }

    private List<Item> items = new ArrayList<Item>();

    /**
     * Defines name of handle for account
     * @param name username of account
     */
    public void setName(String name) {
        this.name = name;
    }

    /**
   * Constructor.
	* Instantiates and sets values for private fields.
	* @param n name of Member
	* @param p password text of member
	* @param c contact information of member
	*
   */	
	public Member(String n, String p, String c)
	{
		name = n;
        locked=false;
		password = p;
		contact = c;
	}
    public Member(){}
  /**
   * Returns name of Member
	* @return name string of Member
	*/
	public String getName()
	{
		return name;
	}
  /**
   * Returns password of Member
	* @return password string of Member
	*/
	public String getPassword()
	{
		return password;
	}
    /**
    * Sets password of Member
	* @param s string of Member
	*/
	public void setPassword(String s)
	{
		password = s;
	}

  /**
   * Returns contact of Member
	* @return contact string of Member
	*/
	public String getContact()
	{
		return contact;
	}
  /**
   * Sets contact of Member
	* @param s string of Member
	*/
	public void setContact(String s)
	{
		contact = s;
	}
	/**
	 * adds item to Members list of lost items
	 * @param i item to add to lost list
	 */
	public void addItem(Item i)
	{
		items.add(i);
	}
	/**
	 * remove item from Members list of lost items
	 * @param i item remove from lost list
	 */
	public void removeItem(Item i)
	{
		items.remove(i);
	}

    public String toString()
    {
        String res=new String("");
        if(this instanceof User)
            res+="TYPE: User\n";
        else res+="TYPE: Admin\n";
        res+=this.name+"\nITEMS:\n";
        int i=0;
        for(Item e:items)
        {
            res+=(i++)+ e.toString()+"\n";
        }
        return res;
    }

}